def pascals_triangle(n):#define a function to create the triangle
    x=[[1]]# X is a list that defines the first row
    for i in range(n-1):
        x.append([sum(i) for i in zip([0]+x[-1],x[-1]+[0])])# append extends the list by addition of values in the range
    return x

for x in pascals_triangle(10):
    print('{0:^39}'.format(x))#the format function gives the output a clear readable outlook
